package com.chong.array;

public class ArrayDemo02 {
    public static void main(String[] args) {
        int[] arrays = {1, 2, 3, 20, 5, 6};
        for (int i = 0; i < arrays.length; i++) {
            System.out.println(arrays[i]);
        }
        //计算所有的元素和

        int sum = 0;
        for (int i = 0; i < arrays.length; i++) {
            sum += arrays[i];
        }
        System.out.println("sum=" + sum);


        //找出最大数
        int maxNum = arrays[0];
        for (int i = 0; i < arrays.length; i++) {
            if (arrays[i] > maxNum) {
                maxNum = arrays[i];
            }
        }
        System.out.println("输入最大值" + maxNum);
    }
}
